// hyb_yl/backstageServices/pages/shoushukuaiyue/shoushukuaiyue.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    argeen: false,
    typs: "",
    xieyi:false,
    neworder:[]
  },
  gosign: function () {
    var that = this
    var pinyin = that.data.pinyin
    var typs = that.data.typs;
    var argeen = that.data.argeen;
    console.log(argeen);
    var openid = wx.getStorageSync('openid')
    if(openid == '')
    {
      wx.showModal({
        cancelColor: '提示',
        content:"请先登录",
        success:function(con)
        {
          if(con.confirm)
          {
            wx.navigateTo({
              url: '/hyb_yl/sgin/sgin',
            })
          }else{
            wx.switchTab({
              url: '/hyb_yl/tabBar/index/index',
            })
          }
        }
      })
    }else if (!argeen) {
      wx.showModal({
        title: '提示',
        content: "请先订阅并同意" + that.data.detail.titles + "协议",
        success: function (con) {
          if (con.confirm) {
            that.setData({
              argeen: true
            })
            wx.navigateTo({
              url: '/hyb_yl/userLife/pages/lianmlist/lianmlist?leixing=lvtong&pinyin='+pinyin + '&id='+that.data.detail.id+ '&name='+that.data.name + '&money='+that.data.info.money
            })
          }
        }
      })
    } else {
      wx.navigateTo({
        url: '/hyb_yl/userLife/pages/lianmlist/lianmlist?leixing=lvtong&pinyin='+pinyin + '&id='+that.data.detail.id+ '&name='+that.data.name + '&money=0'
      })
    }
  },
  radioChange() {
    this.setData({
      argeen: !this.data.argeen,
      xieyi:true
    })
  },
  closezhe:function(){
    this.setData({
      xieyi:false
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var bgc = wx.getStorageSync('color')
    var pinyin = options.ser_key
    var typs = options.typs;
    if (typs == 'query' && typs != undefined) {
      that.setData({
        typs: typs
      })
    }
    
    app.util.request({
      'url': 'entry/wxapp/index.neworder',
      data:{
        type:pinyin
      },
      success: function (res) {
        that.setData({
          neworder: res.data
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
    that.setData({
      pinyin: pinyin
    })
    that.getser_type();
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    app.util.request({
      'url': 'entry/wxapp/index.detailserones',
      data: {
        ser_key: pinyin
      },
      success: function (res) {
        console.log(res)
        that.setData({
          detail: res.data
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
  },
  getser_type:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/green.ser_type",
      data:{
        keyword:that.data.pinyin,
      },
      success:function(res){
        that.setData({
          info:res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})